/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.click.app.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author arnold
 */
@Entity
@Table(name = "entry_products")
public class EntryProduct extends BaseObject implements Serializable {

    private Long id;
    private Date date;
    private Bill bill;
    private Coin coin;
    private Supplier supplier;
    private Float totalPrice;
    private List<EntryProductDetail> entryProductDetails = new ArrayList<EntryProductDetail>();
    private Boolean deleted;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "date")
    @Temporal(javax.persistence.TemporalType.DATE)
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Override
    public String toString() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean equals(Object o) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int hashCode() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * @return the entryProductDetails
     */
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "entryProduct")
    public List<EntryProductDetail> getEntryProductDetails() {
        if (entryProductDetails==null){
            entryProductDetails =  new ArrayList<EntryProductDetail>();
        }
        return entryProductDetails;
    }

    /**
     * @param entryProductDetails the entryProductDetails to set
     */
    public void setEntryProductDetails(List<EntryProductDetail> entryProductDetails) {
        this.entryProductDetails = entryProductDetails;
    }

    /**
     * @return the bill
     */
    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "id_bill")
    public Bill getBill() {
        return bill;
    }

    /**
     * @param bill the bill to set
     */
    public void setBill(Bill bill) {
        this.bill = bill;
    }

    /**
     * @return the coin
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "id_coin")
    public Coin getCoin() {
        return this.coin;
    }

    
    public void setCoin(Coin coin) {
        this.coin = coin;
    }

    /**
     * @return the totalPrice
     */
    public Float getTotalPrice() {
        return totalPrice;
    }

    /**
     * @param totalPrice the totalPrice to set
     */
    public void setTotalPrice(Float totalPrice) {
        this.totalPrice = totalPrice;
    }

    /**
     * @return the deleted
     */
    public Boolean getDeleted() {
        return deleted;
    }

    /**
     * @param deleted the deleted to set
     */
    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    /**
     * @return the supplier
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "id_supplier", nullable = false)
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * @param supplier the supplier to set
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }
}
